<template>
    <School :addStu="addStu"></School>
    <User v-for="(item,index) in userList" 
    :uname="item.uname"
    :age="item.age"></User>
    <button @click="addStu">添加</button>
</template>

<script>
import User from './components/User.vue'
import School from './components/School.vue'
export default {
  name: 'App',
  data(){
    return{
      userList:[
        {uname:'张三',age:18},
        {uname:'李四',age:28},
        {uname:'王五',age:15},
      ]
    }
  },
  methods:{
      addStu(user){
          this.userList.unshift(user);
      }
  },
  components:{
    User,
    School
  }
}
//数组中追加内容  this.userList.unshift
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
</style>
